[skip changelog] Use appropriate name for field that stores library folder name #1900
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please check if the PR fulfills these requirements
before creating one)
our contributing guidelines
UPGRADING.md
has been updated with a migration guide (for breaking changes)What kind of change does this PR introduce?
Bug fix.
What is the current behavior?
Each Arduino library has a name, which is used as its sole identifier by the user in
arduino-cli lib
commands, and by Arduino CLI when referring to the library in messages displayed to the user.The name is defined by:
name
field in thelibrary.properties
metadata fileThe name is resolved when loading the library and stored in the
Name
field of thejiasu.xzqcsaa.nyc.mn/arduino/arduino-cli/arduino/libraries.Library
struct.The name of the library's installation folder is used by Arduino CLI in several other ways, most notably for determining "folder name priority" for use in library dependency resolution. For this reason, the folder name is also stored in the struct when loading the library.
Arduino CLI and arduino-builder have been plagued by problems caused by the inappropriate use of this folder name as the identifier for the library instead of the sole correct identifier (which is only the folder name in the case of "1.0 format" libraries (#932). The design of the
github.com/arduino/arduino-cli/arduino/libraries.Library
struct may have been a contributing factor in those bugs, since at the time of their occurrence the folder name was stored in theName
field, the metadata-defined name in aRealName
. In addition to the fact that no one field could be used as a source of the name in all cases, I suspect the ambiguous field names themselves caused confusion to developers.This situation was improved by providing the library identifier via a single field for all library formats (#1878). The name provided by this field is the "canonical" name of the library. Inexplicably, at that time the field containing the folder name was renamed
CanonicalName
. The string contained by this field is in no way a "canonical" name for the library, so the field name is bound to cause more of the very bugs and confusion the redesign of the struct was intended to prevent.What is the new behavior?
Change the inappropriate
github.com/arduino/arduino-cli/arduino/libraries.Library.CanonicalName
field name to the accurateDirName
.Does this PR introduce a breaking change, and is titled accordingly?
Although the redesign of the
github.com/arduino/arduino-cli/arduino/libraries.Library
struct is a breaking change, this PR is only a patch on the previous PR that introduced the breaking change. Since there hasn't been a release since the time of that change, this PR does not introduce any new breaking changes.